<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD><TITLE>Tk_GetSelection manual page - Tk Library Procedures</TITLE>
<link rel="stylesheet" href="../docs.css" type="text/css" media="all">
</HEAD>
<BODY><H2><a href="../contents.htm">Tcl8.6.11/Tk8.6.11 Documentation</a> <small>&gt;</small> <a href="contents.htm">Tk C API</a> <small>&gt;</small> GetSelect</H2>
<H3><A HREF="../UserCmd/contents.htm">Tcl/Tk Applications</A> | <A HREF="../TclCmd/contents.htm">Tcl Commands</A> | <A HREF="../TkCmd/contents.htm">Tk Commands</A> | <A HREF="../ItclCmd/contents.htm">[incr Tcl] Package Commands</A> | <A HREF="../SqliteCmd/contents.htm">SQLite3 Package Commands</A> | <A HREF="../TdbcCmd/contents.htm">TDBC Package Commands</A> | <A HREF="../TdbcmysqlCmd/contents.htm">tdbc::mysql Package Commands</A> | <A HREF="../TdbcodbcCmd/contents.htm">tdbc::odbc Package Commands</A> | <A HREF="../TdbcpostgresCmd/contents.htm">tdbc::postgres Package Commands</A> | <A HREF="../TdbcsqliteCmd/contents.htm">tdbc::sqlite3 Package Commands</A> | <A HREF="../ThreadCmd/contents.htm">Thread Package Commands</A> | <A HREF="../TclLib/contents.htm">Tcl C API</A> | <A HREF="../TkLib/contents.htm">Tk C API</A> | <A HREF="../ItclLib/contents.htm">[incr Tcl] Package C API</A> | <A HREF="../TdbcLib/contents.htm">TDBC Package C API</A></H3>
<H3><A NAME="M2">NAME</A></H3>
Tk_GetSelection &mdash; retrieve the contents of a selection
<H3><A NAME="M3">SYNOPSIS</A></H3>
<B>#include &lt;tk.h&gt;</B><BR>
int<BR>
<B>Tk_GetSelection</B>(<I>interp, tkwin, selection, target, proc, clientData</I>)<BR>
<H3><A NAME="M4">ARGUMENTS</A></H3>
<DL class="arguments">
<DT><A HREF="../TclLib/Interp.htm">Tcl_Interp</A> <B>*interp</B> (in)<DD>
Interpreter to use for reporting errors.
<P><DT><A HREF="../TkLib/WindowId.htm">Tk_Window</A> <B>tkwin</B> (in)<DD>
Window on whose behalf to retrieve the selection (determines
display from which to retrieve).
<P><DT>Atom <B><A HREF="../TkCmd/selection.htm">selection</A></B> (in)<DD>
The name of the selection to be retrieved.
<P><DT>Atom <B>target</B> (in)<DD>
Form in which to retrieve selection.
<P><DT>Tk_GetSelProc <B>*proc</B> (in)<DD>
Procedure to invoke to process pieces of the selection as they
are retrieved.
<P><DT>ClientData <B>clientData</B> (in)<DD>
Arbitrary one-word value to pass to <I>proc</I>.
<P></DL>
<H3><A NAME="M5">DESCRIPTION</A></H3>
<B>Tk_GetSelection</B> retrieves the selection specified by the atom
<I>selection</I> in the format specified by <I>target</I>.  The
selection may actually be retrieved in several pieces; as each piece
is retrieved, <I>proc</I> is called to process the piece.  <I>Proc</I>
should have arguments and result that match the type
<B>Tk_GetSelProc</B>:
<P>
<PRE>typedef int <B>Tk_GetSelProc</B>(
        ClientData <I>clientData</I>,
        <A HREF="../TclLib/Interp.htm">Tcl_Interp</A> *<I>interp</I>,
        char *<I>portion</I>);</PRE>
<P>
The <I>clientData</I> and <I>interp</I> parameters to <I>proc</I>
will be copies of the corresponding arguments to
<B>Tk_GetSelection</B>.  <I>Portion</I> will be a pointer to
a string containing part or all of the selection.  For large
selections, <I>proc</I> will be called several times with successive
portions of the selection.  The X Inter-Client Communication
Conventions Manual allows a selection to be returned in formats
other than strings, e.g. as an array of atoms or integers.  If
this happens, Tk converts the selection back into a string
before calling <I>proc</I>.  If a selection is returned as an
array of atoms, Tk converts it to a string containing the atom names
separated by white space.  For any other format besides string,
Tk converts a selection to a string containing hexadecimal
values separated by white space.
<P>
<B>Tk_GetSelection</B> returns to its caller when the selection has
been completely retrieved and processed by <I>proc</I>, or when a
fatal error has occurred (e.g. the selection owner did not respond
promptly).  <B>Tk_GetSelection</B> normally returns <B><A HREF="../TclCmd/catch.htm">TCL_OK</A></B>;  if
an error occurs, it returns <B><A HREF="../TclCmd/catch.htm">TCL_ERROR</A></B> and leaves an error message
in interpreter <I>interp</I>'s result.  <I>Proc</I> should also return either
<B><A HREF="../TclCmd/catch.htm">TCL_OK</A></B> or <B><A HREF="../TclCmd/catch.htm">TCL_ERROR</A></B>.  If <I>proc</I> encounters an error in
dealing with the selection, it should leave an error message in the
interpreter result and return <B><A HREF="../TclCmd/catch.htm">TCL_ERROR</A></B>;  this will abort the
selection retrieval.
<H3><A NAME="M6">KEYWORDS</A></H3>
<A href="../Keywords/F.htm#format">format</A>, <A href="../Keywords/G.htm#get">get</A>, <A href="../Keywords/S.htm#selection retrieval">selection retrieval</A>
<div class="copy">Copyright &copy; 1990-1994 The Regents of the University of California.
<BR>Copyright &copy; 1994-1996 Sun Microsystems, Inc.
</div>
</BODY></HTML>
